/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MainForm.java
 *
 * Created on Oct 29, 2011, 8:46:17 AM
 */
package breakers_cna_client;

import breakers_cna_client.requests.ManagerFilesJIF;
import breakers_cna_client.responses.ManagerFiles;

/**
 *
 * @author Hnmtuan
 */
public class MainForm extends javax.swing.JFrame {

    private ManagerFilesJIF _requestFiles;
    private ManagerFiles _responseFiles;
    private Setting _settingForm;
    private String _host;
    private Integer _port;

    public String getHost() {
        return _host;
    }

    public void setHost(String _host) {
        this._host = _host;
    }

    public Integer getPort() {
        return _port;
    }

    public void setPort(Integer _port) {
        this._port = _port;
    }

    /** Creates new form MainForm */
    public MainForm() {
        initComponents();

        _requestFiles = new ManagerFilesJIF(this);
        this.add(_requestFiles);

//        _responseFiles = new ManagerFiles(this);
//        this.add(_responseFiles);

        _settingForm = new Setting(this);
        this.add(_settingForm);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        jMenuItem2 = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem3 = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jMenuBar1.setName("jMenuBar1"); // NOI18N

        jMenu1.setText("Requests"); // NOI18N
        jMenu1.setName("Request_JMenu"); // NOI18N

        jMenuItem1.setText("Manage Request Files"); // NOI18N
        jMenuItem1.setName("ManageRF_MenuItem"); // NOI18N
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu1.add(jMenuItem1);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Responses"); // NOI18N
        jMenu2.setName("Response_JMenu"); // NOI18N

        jMenuItem2.setText("Manage Response Files"); // NOI18N
        jMenuItem2.setName("ManageResponseF_MenuItem"); // NOI18N
        jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem2ActionPerformed(evt);
            }
        });
        jMenu2.add(jMenuItem2);

        jMenuBar1.add(jMenu2);

        jMenu3.setText("Settings");
        jMenu3.setName("jMenu3"); // NOI18N

        jMenuItem3.setText("Main Server"); // NOI18N
        jMenuItem3.setName("jMenuItem3"); // NOI18N
        jMenuItem3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem3ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem3);

        jMenuBar1.add(jMenu3);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 686, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 463, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        if (_requestFiles == null) {
            System.out.println("requestFiles form is empty !");
          return;
        }
       _requestFiles.setHost(_host);
       _requestFiles.setPort(_port);

       _requestFiles.setVisible(true);
        this.pack();
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
        // TODO add your handling code here:
        if (_responseFiles == null) {
            return;
        }
        _responseFiles.setVisible(true);
        this.pack();
    }//GEN-LAST:event_jMenuItem2ActionPerformed

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed
        // TODO add your handling code here:
        if (_settingForm == null) {
            return;
        }
        _settingForm.setVisible(true);
        this.pack();
    }//GEN-LAST:event_jMenuItem3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainForm().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JMenuItem jMenuItem3;
    // End of variables declaration//GEN-END:variables
}
